package com.intelligencesoft.pss.entity.publish;

import java.util.Date;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

import org.hibernate.annotations.GenericGenerator;
import org.hibernate.annotations.NotFound;
import org.hibernate.annotations.NotFoundAction;

import com.intelligencesoft.pss.entity.BasePojo;
import com.intelligencesoft.pss.entity.base.PageBean;
import com.intelligencesoft.pss.entity.base.UserInfo;

@Entity
@Table(name="T_PUBLISH_INFO")
public class PublishInfo extends BasePojo{

	private static final long serialVersionUID = 7069982678912360051L;
	
	private UserInfo userInfo;
	
	private String text;
	
	private String bindingType;
	
	private List<PublishImage> publishImage;
	
	@Id
	@Column(name = "C_ID", nullable = false, length = 32)
	@GeneratedValue(generator = "system-uuid")
	@GenericGenerator(name = "system-uuid", strategy = "uuid")
	public String getId() {
		return super.getId();
	}
	
	public void setId(String id) {
		super.setId(id);
	}
	
	@Column(name="C_CREATE_DATE")
	@Temporal(value=TemporalType.TIMESTAMP)
	public Date getCreateDate() {
		return super.getCreateDate();
	}
	public void setCreateDate(Date createDate) {
		super.setCreateDate(createDate);
	}
	
	@Column(name="C_DESCRIPTION")
	public String getDescription() {
		return super.getDescription();
	}

	public void setDescription(String description) {
		super.setDescription(description);
	}

	@ManyToOne
	@JoinColumn(name="C_USER_ID", referencedColumnName="C_ID")
	@NotFound(action=NotFoundAction.IGNORE)
	public UserInfo getUserInfo() {
		return userInfo;
	}

	public void setUserInfo(UserInfo userInfo) {
		this.userInfo = userInfo;
	}

	@Column(name="C_TEXT")
	public String getText() {
		return text;
	}

	public void setText(String text) {
		this.text = text;
	}

	@Column(name="C_BINDING_TYPE")
	public String getBindingType() {
		return bindingType;
	}

	public void setBindingType(String bindingType) {
		this.bindingType = bindingType;
	}
	
	@OneToMany(mappedBy="publishInfo",targetEntity=PublishImage.class,cascade = CascadeType.REFRESH, fetch = FetchType.LAZY)
	public List<PublishImage> getPublishImage() {
		return publishImage;
	}
	
	public void setPublishImage(List<PublishImage> publishImage) {
		this.publishImage = publishImage;
	}
}
